package com.ycsj.goldmedalnewconcept.tips;

import com.ycsj.goldmedalnewconcept.R;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.media.AudioManager;
import android.media.MediaPlayer;
import android.media.RingtoneManager;
import android.net.Uri;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;

public class AlarmAlert extends Activity {
	MediaPlayer mMediaPlayer = new MediaPlayer();
	private String content;
	private String title;

	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		
		
		content = getIntent().getStringExtra("content");
		title = getIntent().getStringExtra("title");
		if(TextUtils.isEmpty(content)||content==null){
			content = "备忘录事件";
		}
		if(TextUtils.isEmpty(title)||title==null){
			title = "备忘录提醒";
		}
		mMediaPlayer.setLooping(true);
		Uri mediaUri = RingtoneManager
				.getDefaultUri(RingtoneManager.TYPE_ALARM);
		try {
			System.out.println("Timedown " + mediaUri.toString());
			mMediaPlayer.setDataSource(this, mediaUri);
			// mMediaPlayer.setAudioStreamType(AudioManager.STREAM_ALARM);
			mMediaPlayer.prepare();
			mMediaPlayer.start();

		} catch (Exception e) {
			System.out.println("Timedown " + e.toString());
		}

		new AlertDialog.Builder(AlarmAlert.this)
				.setIcon(R.drawable.iconjpj)
				.setTitle(title)
				.setMessage(content)
				.setPositiveButton("知道了",
						new DialogInterface.OnClickListener() {
							public void onClick(DialogInterface dialog,
									int whichButton) {
								mMediaPlayer.stop();
								mMediaPlayer.release();
								AlarmAlert.this.finish();
							}
						}).show();
	}
}